/**
 * licenses
 *
 */
package com.openjawtech.xscraper.flights.domain;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * <p> an entity mapping to the airport table in db
 *
 * <p>15/02/2009
 * @author Wenbo.Sun
 */
@Entity
@Table(name = "airport")
public class Airport implements java.io.Serializable {
    private static final long serialVersionUID = 1L;

	private Integer airportId;
	private String airportName;
	private Set<Flight> flightsForArrivalId = new HashSet<Flight>(0);
	private Set<Flight> flightsForDepartureId = new HashSet<Flight>(0);

	// Constructors

	/** default constructor */
	public Airport() {
	}

    public Airport(Integer airportId) {
        this.airportId = airportId;
    }

	/** full constructor */
	public Airport(String airportName, Set<Flight> flightsForArrivalId,
			Set<Flight> flightsForDepartureId) {
		this.airportName = airportName;
		this.flightsForArrivalId = flightsForArrivalId;
		this.flightsForDepartureId = flightsForDepartureId;
	}

    public Airport(String airportName) {
        this.airportName = airportName;
    }

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "airport_id", unique = true, nullable = false)
	public Integer getAirportId() {
		return this.airportId;
	}

	public void setAirportId(Integer airportId) {
		this.airportId = airportId;
	}

	@Column(name = "airport_name", length = 100)
	public String getAirportName() {
		return this.airportName;
	}

	public void setAirportName(String airportName) {
		this.airportName = airportName;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "airportByArrivalId")
	public Set<Flight> getFlightsForArrivalId() {
		return this.flightsForArrivalId;
	}

	public void setFlightsForArrivalId(Set<Flight> flightsForArrivalId) {
		this.flightsForArrivalId = flightsForArrivalId;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "airportByDepartureId")
	public Set<Flight> getFlightsForDepartureId() {
		return this.flightsForDepartureId;
	}

	public void setFlightsForDepartureId(Set<Flight> flightsForDepartureId) {
		this.flightsForDepartureId = flightsForDepartureId;
	}

}